import {config, request} from 'utils'

const {api} = config
const {customer, highQualityChatRecord, address} = api

export function query (params) {
  const {address} = params
  if (address) {
    params.provinceId = address[0]
    params.cityId = address[1]
    params.areaId = address[2]
    params.address = undefined
  }
  return request({
    url: customer,
    method: 'get',
    data: params,
  })
}

export function stat() {
  return request({
    url: customer + '/stat',
    method: 'get',
  })
}

export function queryById (params) {
  return request({
    url: customer + '/findById',
    method: 'get',
    data: params,
  })
}

export function remove (params) {
  return request({
    url: customer + '/delete',
    method: 'post',
    data: params,
  })
}

export function create (params) {
  return request({
    url: customer,
    method: 'post',
    data: params,
  })
}

export function update (params) {
  return request({
    url: customer,
    method: 'put',
    data: params,
  })
}

export function delAddr (params) {
  return request({
    url: address,
    method: 'delete',
    data: params,
  })
}


export function updateAddr (params) {
  return request({
    url: address,
    method: 'put',
    data: params,
  })
}

export function save (params) {
  return request({
    url: highQualityChatRecord,
    method: "post",
    data: params,
  })
}

export function saveAddr (params) {
  return request({
    url: address,
    method: "post",
    data: params,
  })
}

export function queryAddress (params) {
  return request({
    url: address + '/findList',
    method: "get",
    data: params,
  })
}
